package org.firefly.fx.service.common.impl;

import org.apache.commons.lang.StringUtils;
import org.firefly.fx.service.common.IReceiveService;
import org.firefly.fx.vo.RouteMessage;
import org.springframework.stereotype.Service;

@Service
public class RouteServiceImpl extends AbstractRouteServiceImpl {
	@Override
	public void route(RouteMessage routeMsg) {
		if(routeMsg==null){
			return;
		}
		
		if(StringUtils.isBlank(routeMsg.getService()) || StringUtils.isBlank(routeMsg.getUserId())){
			return ;
		}
		
		try{
			IReceiveService  receiveService = super.getServiceImpl(routeMsg.getService());
			if(receiveService!=null){
				receiveService.receive(routeMsg);
			}else{
				logger.error("route service not found!",routeMsg);
			}
		}catch (Exception e) {
			logger.error("route error!",e);
		}
	}
	
}